# Find Compro's MUSE CSTSHARED SDK
# This module defines
# MERSIVE_FOUND
# MERSIVE_INCLUDE_DIR
# On windows:
#   UNSUPPORTED
# On other platforms
#   MERSIVE_CALIBRATOR_LIBRARY
#   MERSIVE_REMOTERENDER_LIBRARY
#   MERSIVE_REMOTERENDERDP_LIBRARY
#

IF (UNIX)
    SET(MERSIVE_ARCH "linux")
#    MESSAGE(STATUS "Looking for Mersive SDK!!")


    FIND_PATH(MERSIVE_INCLUDE_DIR MersiveRuntimeWarper.h
        "$ENV{MERSIVE_ROOT}/include"
        "$ENV{MERSIVE_PATH}/include"
        ${MERSIVE_DIR}/INCLUDE_DIRECTORIES
        $ENV{MERSIVE_DIR}/include
        /usr/local/include
        /usr/include
        /mersive/include
    )

#    IF (MERSIVE_INCLUDE_DIR)
#        MESSAGE(STATUS "Found MERSIVE_INCLUDE_DIR: ${MERSIVE_INCLUDE_DIR}")
#    ELSE (MERSIVE_INCLUDE_DIR )
#        MESSAGE(STATUS "Did not find MERSIVE_INCLUDE_DIR: ${MERSIVE_INCLUDE_DIR}")
#    ENDIF (MERSIVE_INCLUDE_DIR)

    MACRO(FIND_MERSIVE_LIBRARY MYLIBRARY MYLIBRARYNAME)

        FIND_LIBRARY(${MYLIBRARY}
        NAMES ${MYLIBRARYNAME}
        PATHS
            ${MERSIVE_DIR}/lib
            $ENV{MERSIVE_DIR}/lib
            $ENV{MERSIVE_DIR}
            $ENV{MERSIVE_PATH}/lib
            /mersive/lib
            /usr/local/lib
            /usr/local/lib64
            /usr/lib
            /sw/lib
            /opt/local/lib
            /opt/csw/lib
            /opt/lib
            /usr/freeware/lib64
            PATH_SUFFIXES
            ${MUSE_ARCH}
        )

    ENDMACRO(FIND_MERSIVE_LIBRARY MYLIBRARY MYLIBRARYNAME)

    FIND_MERSIVE_LIBRARY(MERSIVE_CALIBRATOR_LIBRARY "MersiveCalibrator")
    FIND_MERSIVE_LIBRARY(MERSIVE_REMOTERENDER_LIBRARY "remoterenderer")
    FIND_MERSIVE_LIBRARY(MERSIVE_REMOTERENDERDP_LIBRARY "EwbRemoteRendererDeviceProxy")

#    MESSAGE(STATUS "MERSIVE_INCLUDE_DIR: ${MERSIVE_INCLUDE_DIR}")
#    MESSAGE(STATUS "MERSIVE_CALIBRATOR_LIBRARY: ${MERSIVE_CALIBRATOR_LIBRARY}")
#    MESSAGE(STATUS "MERSIVE_REMOTERENDER_LIBRARY: ${MERSIVE_REMOTERENDER_LIBRARY}")
#    MESSAGE(STATUS "MERSIVE_REMOTERENDERDP_LIBRARY: ${MERSIVE_REMOTERENDERDP_LIBRARY}")

    SET(MERSIVE_FOUND FALSE)
    IF (MERSIVE_INCLUDE_DIR AND MERSIVE_CALIBRATOR_LIBRARY AND MERSIVE_REMOTERENDER_LIBRARY AND MERSIVE_REMOTERENDERDP_LIBRARY)
       SET(MERSIVE_FOUND TRUE)
    ELSE (MERSIVE_INCLUDE_DIR AND MERSIVE_LIBRARY)
       MESSAGE(STATUS "Did not Find: ${MERSIVE_LIBRARY}")
    ENDIF (MERSIVE_INCLUDE_DIR AND MERSIVE_CALIBRATOR_LIBRARY AND MERSIVE_REMOTERENDER_LIBRARY AND MERSIVE_REMOTERENDERDP_LIBRARY)

    IF (MERSIVE_FOUND)
       IF (NOT MERSIVE_FIND_QUIETLY)
          MESSAGE(STATUS "Found All MERSIVE LIBRARIES")
       ENDIF (NOT MERSIVE_FIND_QUIETLY)
    ELSE (MERSIVE_FOUND)
       IF (MERSIVE_FIND_REQUIRED)
          MESSAGE(FATAL_ERROR "Could not find All Mersive Libraries")
       ENDIF (MERSIVE_FIND_REQUIRED)
    ENDIF (MERSIVE_FOUND)

ENDIF (UNIX)
